Method for encoding images, and an image coder

ABSTRACT

The invention relates to a method for encoding a digital image, in which method the digital image is divided into blocks (C, L, U, UL, UR). In the method a spatial prediction for a block (C) is performed to reduce the amount of information to be transmitted, wherein at least one prediction method (P1-P13) is defined. In the method a classification is determined for at least one neighbouring block (L, U) of said block (C) to be predicted according to the contents of said neighbouring block (L, U), and a prediction method (P1-P13) is selected for the current block (C) on the basis of at least one said classification.

CROSS-REFERENCE TO RELATED APPLICATIONS

Not Applicable

STATEMENT REGARDING FEDERALLY SPONSORED RESEARCH OR DEVELOPMENT

Not Applicable

INCORPORATION-BY-REFERENCE OF MATERIAL SUBMITTED ON A COMPACT DISC

Not Applicable

BACKGROUND OF THE INVENTION

(1) Field of the Invention

The present invention relates to a method for encoding images accordingto the preamble of claim 1. The present invention also relates to adevice for encoding images according to the preamble of claim 12.Furthermore, the present invention relates to an encoder according tothe preamble of claim 23, to a decoder according to the preamble ofclaim 24, to a codec according to the preamble of claim 25, to a mobileterminal according to the preamble of claim 26, and a storage medium forstoring a software program according to the preamble of claim 27.

(2) Description of Related Art Including Information Disclosed Under 37CFR 1.97 and 1.97

The image can be any digital image, a video image, a TV image, an imagegenerated by a video recorder, a computer animation, a still image, etc,In general, a digital image consists of pixels, are arranged inhorizontal and vertical lines, the number of which in a single image istypically tens of thousands. In addition, the information generated foreach pixel contains, for instance, luminance information relating to thepixel, typically with a resolution of eight bits, and in colourapplications also chrominance information, e.g. a chrominance signal.This chrominance signal generally consists of two components, Cb and Cr,which are both typically transmitted with a resolution of eight bits. Onthe basis of these luminance and chrominance values, it is possible toform information corresponding to the original pixel on the displaydevice of a receiving video terminal. In this example, the quantity ofdata to be transmitted for each pixel is 24 bits uncompressed. Thus, thetotal amount of information for one image amounts to several megabits.In the transmission of a moving image, several images are transmittedper second. For instance in a TV image, 25 images are transmitted persecond. Without compression, the quantity of information to betransmitted would amount to tens of megabits per second. However, forexample in the Internet data network, the data transmission rate can bein the order of 64 kbits per second, which makes uncompressed real timeimage transmission via this network practically impossible.

To reduce the amount of information to be transmitted, a number ofdifferent compression methods have been developed, such as the JPEG,MPEG and H.263 standards. In the transmission of video, imagecompression can be performed either as inter-frame compression,intra-frame compression, or a combination of these. In interframecompression, the aim is to eliminate redundant information in successiveimage frames. Typically, images contain a large amount of non-varyinginformation, for example a motionless background, or slowly changinginformation, for example when the subject moves slowly. In inter-framecompression, it is also possible to utilize motion compensatedprediction, wherein the aim is to detect elements in the image which aremoving, wherein motion vector and prediction error information aretransmitted instead of transmitting the pixel values.

To enable the use of image compression techniques in real time, thetransmitting and receiving video terminal should have a sufficientlyhigh processing speed that it is possible to perform compression anddecompression in real time.

In several image compression techniques, an image signal in digitalformat is subjected to a discrete cosine transform (DCT) before theimage signal is transmitted to a transmission path or stored in astorage means. Using a DCT, it is possible to calculate the frequencyspectrum of a periodic signal, i.e. to perform a transformation from thetime domain to the frequency domain. In this context, the word discreteindicates that separate pixels instead of continuous functions areprocessed in the transformation. In a digital image signal, neighbouringpixels typically have a substantial spatial correlation. One feature ofthe DCT is that the coefficients established as a result of the DCT arepractically uncorrelated; hence, the DCT conducts the transformation ofthe image signal from the time domain to the (spatial) frequency domainin an efficient manner, reducing the redundancy of the image data. Assuch, use of transform coding is an effective way of reducing redundancyin both inter-frame and intra-frame coding.

Current block-based coding methods used in still image coding and videocoding for independently coded key frames (intra-frames) use ablock-based approach. In general, an image is divided into N×M blocksthat are coded independently using some kind of transform coding. Pureblock-based coding only reduces the inter-pixel correlation within aparticular block, without considering the inter-block correlation ofpixels. Therefore, pure block-based coding produces rather high bitrates even when using transform-based coding, such as DCT coding, whichhas very efficient energy packing properties for highly correlated data.Therefore, current digital image coding standards exploit certainmethods that also reduce the correlation of pixel values between blocks.

Current digital image coding methods perform prediction in the transformdomain, i.e. they try to predict the DCT coefficients of a blockcurrently being coded using the previous coded blocks and are thuscoupled with the compression method. Typically a DCT coefficient thatcorresponds to the average pixel value within an image block ispredicted using the same DCT coefficient from the previous coded block.The difference between the actual and predicted coefficient is sent todecoder. However, this scheme can predict only the average pixel value,and it is not very efficient.

Prediction of DCT coefficients can also be performed using spatiallyneighbouring blocks. For example, a DCT coefficient that corresponds tothe average pixel value within a block is predicted using the DCTcoefficient(s) from a block to the left or above the current block beingcoded. DCT coefficients that correspond to horizontal frequencies (i.e.vertical edges) can be predicted from the block above the current blockand coefficients that correspond to vertical frequencies (i.e.horizontal edges) can be predicted from the block situated to the left.Similar to the previous method, differences between the actual andpredicted coefficients are coded and sent to the decoder. This approachallows prediction of horizontal and vertical edges that run throughseveral blocks.

In MPEG-2 compression, the DCT is performed in blocks using a block sizeof 8×8 pixels. The luminance level is transformed using full spatialresolution, while both chrominance signals are subsampled. For example,a field of 16×16 pixels is subsampled into a field of 8×8 pixels. Thedifferences in the block sizes are primarily due to the fact that theeye does not discern changes in chrominance equally well as changes inluminance, wherein a field of 2×2 pixels is encoded with the samechrominance value.

The MPEG-2 standard defines three frame types: an I-frame (Intra), aP-frame (Predicted), and a B-frame (Bi-directional). An I-frame isgenerated solely on the basis of information contained in the imageitself, wherein at the receiving end, an I-frame can be used to form theentire image. A P-frame is typically formed on the basis of the closestpreceding I-frame or P-frame, wherein at the receiving stage thepreceding I-frame or P-frame is correspondingly used together with thereceived P-frame. In the composition of P-frames, for instance motioncompensation is used to compress the quantity of information. B-framesare formed on the basis of a preceding I-frame and a following P- orI-frame. Correspondingly, at the receiving stage it is not possible tocompose the B-frame until the preceding and following frames have beenreceived. Furthermore, at the transmission stage the order of the P- andB-frames is changed, wherein the P-frame following the B-frame isreceived first. This tends to accelerate reconstruction of the image inthe receiver.

Intra-frame coding schemes used in prior art solutions are inefficient,wherein transmission of intra-coded frames is bandwidth-excessive. Thislimits the usage of independently coded key frames in low bit ratedigital image coding applications.

The present invention addresses the problem of how to further reduceredundant information in image data and to produce more efficient codingof image data, by introducing a spatial prediction scheme involving theprediction of pixel values, that offers a possibility for predictionfrom several directions. This allows efficient prediction of edges withdifferent orientations, resulting in considerable savings in bit rate.The method according to the invention also uses context-dependentselection of suitable prediction methods, which provides further savingsin bit rate.

The invention introduces a method for performing spatial prediction ofpixel values within an image. The technical description of this documentintroduces a method and system for spatial prediction that can be usedfor block-based still image coding and for intra-frame coding inblock-based video coders Key elements of the invention are the use ofmultiple prediction methods and the context-dependent selection andsignalling of the selected prediction method. The use of multipleprediction methods and the context-dependent selection and signalling ofthe prediction methods allow substantial savings in bit rate to beachieved compared with prior art solutions.

It is an object of the present invention to improve encoding anddecoding of digital images such that higher encoding efficiency can beachieved and the bit rate of the encoded digital image can be furtherreduced.

According to the present invention, this object is achieved by anencoder for performing spatially predicted encoding of image data.

BRIEF DESCRIPTION OF THE INVENTION

According to a first aspect of the invention there is provided a methodfor encoding a digital image, in which method the digital image isdivided into blocks, characterized in that in the method a spatialprediction for a block is performed to reduce the amount of informationto be transmitted, wherein at least one prediction method is defined, aclassification is determined for at least one neighbouring block of saidblock to be predicted according to the contents of said neighbouringblock, and a prediction method is selected for the current block on thebasis of at least one said classification.

According to a second aspect of the invention there is provided a devicefor encoding a digital image, which is divided into blocks,characterized in that the device comprises means for performing spatialprediction for a block to reduce the amount of information to betransmitted, wherein at least one prediction method has been defined,that the device further comprises means for determining a classificationfor at least one neighbouring block of said block to be predictedaccording to the contents of said neighbouring block, and means forselecting a prediction method for the current block on the basis of atleast one said classification.

According to a third aspect of the invention there is provided anencoder comprising means for encoding a digital image, and means fordividing the digital image into blocks, characterized in that theencoder comprises means for performing spatial prediction for a block toreduce the amount of information to be transmitted, wherein at least oneprediction method has been defined, that the encoder further comprisesmeans for determining a classification for at least one neighbouringblock of said block to be predicted according to the contents of saidneighbouring block, and means for selecting a prediction method for thecurrent block on the basis of at least one said classification.

According to a fourth aspect of the invention there is provided adecoder comprising means for decoding a digital image, which is dividedinto blocks, characterized in that the decoder comprises means forperforming spatial prediction for a block to reduce the amount ofinformation to be transmitted, wherein at least one prediction methodhas been defined, that the decoder further comprises means fordetermining a classification for at least one neighbouring block of saidblock to be predicted according to the contents of said neighbouringblock, and means for selecting a prediction method for the current blockon the basis of at least one said classification.

According to a fifth aspect of the invention there is provided a codeccomprising means for encoding a digital image, means for dividing thedigital image into blocks, and means for decoding a digital image,characterized in that the codec comprises means for performing spatialprediction for a block to reduce the amount of information to betransmitted, wherein at least one prediction method has been defined,that the codec further comprises means for determining a classificationfor at least one neighbouring block of said block to be predictedaccording to the contents of said neighbouring block, and means forselecting a prediction method for the current block on the basis of atleast one said classification.

According to a sixth aspect of the invention there is provided a mobileterminal comprising means for encoding a digital image, means fordividing the digital image into blocks, and means for decoding a digitalimage, characterized in that the mobile terminal comprises means forperforming spatial prediction for a block to reduce the amount ofinformation to be transmitted, wherein at least one prediction methodhas been defined, that the mobile terminal further comprises means fordetermining a classification for at least one neighbouring block of saidblock to be predicted according to the contents of said neighbouringblock, and means for selecting a prediction method for the current blockon the basis of at least one said classification.

According to a seventh aspect of the invention there is provided astorage medium for storing a software program comprising machineexecutable steps for encoding a digital image, and for dividing thedigital image into blocks, characterized in that the software programfurther comprises machine executable steps for performing spatialprediction for a block to reduce the amount of information to betransmitted, wherein at least one prediction method has been defined,steps for determining a classification for at least one neighbouringblock of said block to be predicted according to the contents of saidneighbouring block, and steps for selecting a prediction method for thecurrent block on the basis of at least one said classification.

The invention is based on the idea that to perform spatial prediction ofpixel values for a block to be coded, adjacent decoded blocks areexamined to determine if there exists some directionality in thecontents of the adjacent blocks. This directionality information is thenused to classify the blocks. Based on the combination of the classes ofthe adjacent blocks, the contents (pixel values) of the current blockare then predicted using a suitable prediction method. The predictionmethod is signalled to the decoder. Prediction error information is alsosent if it is efficient to do that in a distortion vs. bit-rate sense.

Considerable advantages are achieved with the present invention whencompared with solutions of prior art. Using a method according to theinvention, it is possible to reduce the amount of information neededwhen transmitting images in digital format.

In general, the method according to the invention can be applied toblock-based still image coding as well as to intra-frame coding in ablock-based digital image coder.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWING(S)

In the following, the invention will be described in more detail withreference to the appended figures, in which

FIG. 1 shows the structure of a digital image transmission system,

FIG. 2 illustrates the spatial prediction method of the presentinvention in the form of a block diagram,

FIGS. 3 a-3 c show an illustration of blocks that are used forprediction according to an advantageous embodiment of the presentinvention,

FIG. 4 shows the mapping of directionality classes to context classesaccording to an advantageous embodiment of the present invention,

FIGS. 5 a-5 p show an illustration of pixels that are used forprediction according to an advantageous embodiment of the presentinvention,

FIG. 6 shows an advantageous bit-stream syntax used in the transmissionof displacement information, and

FIG. 7 is a schematic representation of a portable communications deviceimplementing a method according to the invention.

DETAILED DESCRIPTION OF THE INVENTION

The intra-frame prediction method described in this invention operatesin a block-based manner and can be applied to image frames that compriseN×M blocks scanned e.g. row by row from left to right and from top tobottom. It is obvious that other scanning directions can also be used inconnection with the present invention. Spatial prediction is performedfor each intra-coded block using previously reconstructed blocks in thesame frame. The residual error can be compressed using any suitablemethod, e.g. using DCT, as in current standards. It should also beappreciated that the method according to the invention may be appliedequally well to both monochrome and colour images.

The system according to the invention consists of two main parts, asillustrated in FIG. 2. Firstly, context-dependent selection 17 of asuitable subset of prediction methods is performed by classifyingneighbouring reconstructed blocks. Secondly, a prediction block isconstructed 18 using one of the prediction methods in the selectedsubset and the prediction method is signalled to decoder.

Context-dependent selection of a prediction method subset comprisesdirectionality classification of possible neighbouring blocks, mappingof directionality classes to context classes and context-dependentselection of an appropriate prediction method subset.

In the following, the transmission and reception of digital image framesin a transmission system is described with reference to the digitalimage transfer arrangement presented in FIG. 1. The current framearrives at the transmission system 1 as input data 2 provided, forexample, as the output of a digital video camera. The current frame maybe provided in its entirety (i.e. a complete frame comprising N×M imageblocks), in which case the frame is stored, or the transmission system 1may receive the input data block by block. The blocks of the frame aredirected one by one to a summer 4, where prediction error of a block iscalculated e.g. by subtracting a block of the frame from a predictedblock. The prediction error is coded in a coder 5 and decoded in adecoder 6. In summer 7 the decoded prediction error is summed withpredicted blocks and the result is saved in a frame memory 8. Theprediction estimator 3, where spatial prediction is performed accordingto the method of the invention, receives blocks to be used withprediction from the frame memory 8.

In order to form a new prediction block, the prediction estimator 3examines, if there exists some directionality in possible neighbouringblocks of the current block. This scheme is illustrated in FIG. 3 a. Thereference C denotes the current block, the reference L denotes a firstneighbouring block of the current block and the reference U denotes asecond neighbouring block of the current block. In this advantageousembodiment of the invention, the first neighbouring block is to the leftof the current block C and the second neighbouring block is above thecurrent block C. If the scanning order is different from left to rightand from top to bottom, the first neighbouring block L and the secondneighbouring block U are not necessarily to the left of and above thecurrent block C, respectively. The neighbouring blocks L, U are blocksadjacent to the current block C which have already been reconstructed.

In some embodiments of the invention more than two blocks can beclassified and used to select the prediction method for the currentblock C. However, in the following description of a preferred embodimentof the invention, a maximum of two neighbouring blocks L, U areclassified for each block C under examination. Furthermore, theclassification is performed only if a neighbouring block L or U exists.If a current block does not have any neighbouring blocks, it is treatedas “Non-Intra” during context-dependent selection of prediction methods,as will be explained further later in the text.

Prediction can also be implemented in such a way that it is performedusing only already reconstructed intra-coded blocks. In this case, allblocks other than intra-coded blocks are treated as “Non-Intra”.

The first neighbouring block L and the second neighbouring block U areclassified according to the directionality of image details inside theblock. As illustrated in FIG. 2, directionality classifier 19 analysesthe directionality of the neighbouring blocks using pixel valuegradients. As a result, each neighbouring block is mapped 20 into anoutput class. In an advantageous embodiment of the invention there are11 such output classes, but it is obvious that the number of outputclasses may vary. Advantageously, the output classes consist of 8directionality classes D0-D7 corresponding to edge orientations k·22.5°,k=0, 1, . . . , 7 and 3 non-directional classes D8-D10 corresponding toflat, smooth texture and coarse texture blocks, In alternativeembodiments of the invention, the number of directionality classes andthe way in which they are defined may vary.

In the system of FIG. 1, the prediction estimator 3 first examines ifthe first neighbouring block L and/or the second neighbouring block Uexist. If either one of these blocks does not exist, that neighbouringblock is defined as a C0 block (“Non-Intra”), i.e. the current block Cis on the edge or in a corner of the frame, or on the edge or in acorner of an area consisting of Intra blocks. Then, the predictionestimator 3 selects a suitable prediction method for the current blockC, as described later in this description. Otherwise, the predictionestimator 3 calculates gradient information relating to the block orblocks L, U.

There are many suitable methods for calculating the gradientinformation. In the following, one advantageous method is described.First, average absolute directional gradients g_(k), k=0, 1, . . . , 7of a block L, U are defined as $\begin{matrix}{{g_{0} = {\frac{1}{N\left( {N - 1} \right)}{\max\left( {1,{\sum\limits_{y = 0}^{N - 1}{\sum\limits_{x = 0}^{N - 2}{{{I\left( {x,y} \right)} - {I\left( {{x + 1},y} \right)}}}}}} \right)}}}{g_{1} = {\frac{1}{\left( {N - 1} \right)^{2}\max}\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 1}{{{I\left( {x,y} \right)} - {\frac{1}{2}\left( {{I\left( {{x - 1},y} \right)} + {I\left( {{x - 1},{y + 1}} \right)}} \right)}}}}}} \right)}}{g_{2} = {\frac{1}{\left( {N - 1} \right)^{2}}\max\quad\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 1}{{{I\left( {x,y} \right)} - {I\left( {{x - 1},{y + 1}} \right)}}}}}} \right)}}{g_{3} = {\frac{1}{\left( {N - 1} \right)^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 1}{{{I\left( {x,y} \right)} - {\frac{1}{2}\left( {{I\left( {{x - 1},{y + 1}} \right)} + {I\left( {x,{y + 1}} \right)}} \right)}}}}}} \right)}}}{g_{4} = {\frac{1}{{N\left( {N - 1} \right)}^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 1}{{{I\left( {x,y} \right)} - {I\left( {x,{y + 1}} \right)}}}}}} \right)}}}{g_{5} = {\frac{1}{\left( {N - 1} \right)^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 2}{{{I\left( {x,y} \right)} - {\frac{1}{2}\left( {{I\left( {x,{y + 1}} \right)} + {I\left( {{x + 1},{y + 1}} \right)}} \right)}}}}}} \right)}}}{g_{6} = {\frac{1}{\left( {N - 1} \right)^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 2}{{{I\left( {x,y} \right)} - {I\left( {{x + 1},{y + 1}} \right)}}}}}} \right)}}}{g_{7} = {\frac{1}{\left( {N - 1} \right)^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}\left. {{\sum\limits_{x = 0}^{N - 2}{{{I\left( {x,y} \right)} - {\frac{1}{2}\left( {{I\left( {{x + 1},y} \right)} + {I\left( {{x + 1},{y + 1}} \right)}} \right.}}}}} \right)}} \right)}}}} & (1)\end{matrix}$where N is the size of the block and I(x,y) represent the pixelintensity values. Indices x and y reter to the co-ordinates of a pixelinside the block and k represents edge orientations. The predictionestimator 3 calculates the gradient values g_(k) according to theformulae above.

Using the gradient values g_(k), gradient ratios r_(k), k=0, 1, . . . ,7 are defined as the ratio between the gradient value in a certaindirection and gradient value in the orthogonal direction:$\begin{matrix}{{r_{0} = \frac{g_{0}}{g_{4}}},{r_{1} = \frac{g_{1}}{g_{5}}},{r_{2} = \frac{g_{2}}{g_{6}}},{r_{3} = \frac{g_{3}}{g_{7}}},{r_{4} = \frac{1}{r_{0}}},{r_{5} = \frac{1}{r_{1}}},{r_{6} = \frac{1}{r_{2}}},{r_{7} = \frac{1}{r_{3}}},} & (2)\end{matrix}$

Based on the absolute gradient values g_(k) and gradient ratios r_(k)defined in (1) and (2), classification of the block is performed,advantageously according to the following classification steps 1-12using some numerical values as thresholds. This classification processclassifies each of the neighbouring blocks into one of a first set ofblock types D0-D10. The present invention is not limited to the valuesused in the algorithm, but the values used in the algorithm in thefollowing steps are preferred. The method can also be applied to anyblock size.

In this advantageous embodiment of the invention the classificationphase comprises 13 steps, but it is obvious that the classification maycomprise also different number of steps.

Step 1

In this step the flatness of the block is checked. Prediction estimator3 calculates gradient values g₀ and g₄. These correspond to gradientvalues for horizontal (0°) and vertical (90°) image details. If bothg₀≦2.0 and g₄≦2.0, the block is classified as class D8 and the initialclassification process terminates. Otherwise, classification step 2 isperformed.

Step 2

In this step a further check for flatness of the block is performed. Therest of the gradient values g_(k) are calculated, and the maximumgradient value g_(max)=max{g_(k)} is determined. The maximum gradientvalue g_(max) is compared with 2.5. If g_(max)≦2.5 the block isclassified as class D8 and the initial classification processterminates. Otherwise, the method continues from step 3.

Step 3

In step 3 a check for clear directionality is performed. The gradientratios r_(k) are calculated and the minimum gradient ratior_(min)=min{r_(k)} is determined. When the minimum gradient ratio isfound, the corresponding index k_(min) is defined. If r_(min)≦0.15 theblock is classified to corresponding class Dk_(min) and the methodcontinues from step 12, otherwise the method continues from step 4.

Step 4

In step 4 a check for texture is performed. The minimum gradient ratior_(min) is compared with 0.6. If r_(min)≧0.6 the method continues fromstep 13, otherwise the method continues from the next step.

Step 5

In step 5 the two smallest gradient ratios are checked to determine ifthey are clearly distinct. The gradient ratios r_(k) are sorted inincreasing order r₍₀₎≦r₍₁₎≦r₍₂₎ . . . ≦r₍₇₎. Also the gradient ratioindices are reordered according to the sorted order k₍₀₎, k₍₁₎, k₍₂₎, .. . k₍₇₎. If r₍₁₎−r₍₀₎<⅓(r₍₂₎−r₍₁₎) the sixth classification step isperformed next, otherwise the method continues from the 10thclassification step.

Step 6

In step 6 the smallest gradient ratio is checked to determine if itcorresponds to directionality class D2 or D6 and the smallest gradientratio is small enough. The prediction estimator 3 first examines,whether the index of the gradient ratio r₍₀₎ is either 2 or 6, whereinthe first gradient ratio r₍₀₎ is compared with 0.6. Ifr₍₀₎ε{r_(k)|k=2,6} and R₍₀₎<0.6, the block is classified ascorresponding to class Dk₍₀₎ and the method continues from step 12.Otherwise the method continues from step 7.

Step 7

In step 7 the prediction estimator 3 first examines if the index of thesecond gradient ratio R₍₁₎ is either 2 or 6, wherein the first gradientratio R₍₀₎ is compared with 0.6. If r₍₁₎ε{r_(k)|k=2,6} and R₍₀₎<0.6 theblock is classified as corresponding to class Dk₍₁₎ and the methodcontinues from the step 12, otherwise the method continues from Step 8.

Step 8

In step 8 the smallest gradient ratio is checked to determine if itcorresponds to directionality class D1, D3, D5 or D7 and the smallestgradient ratio is small enough. The first gradient ratio r₍₀₎ iscompared with 0.5. If r₍₀₎ε{r_(k)|k=1,3,5,7} and R₍₀₎<0.5 the block isclassified as corresponding to class Dk₍₀₎ and the method continues fromstep 12, otherwise the method continues from step 9.

Step 9

In step 9 the second gradient ratio is checked to determine if itcorresponds to directionality class D1, D3, D5 or D7 and the smallestgradient ratio is small enough. The first gradient ratio R₍₀₎ iscompared with 0.5, if r₍₁₎ε{r_(k)|k=1,3,5,7}. If R₍₀₎<0.5 the block isclassified as corresponding to class Dk₍₁₎ and the method continues fromstep 12. Otherwise the method continues from step 10.

Step 10

Directionality is not yet found, therefore a (somewhat) higher thresholdvalue compared with the threshold value used in Step 3 can be used tocheck the directionality. This means that a more uncertain examinationis performed. Step 10 uses the values of threshold T₁ defined in Table1, below. The values for T₁ are compared with the first gradient ratio.If R₍₀₎<T₁ as defined in Table 1, the block is classified ascorresponding to class Dk₍₀₎ and the method continues from step 12.Otherwise the method continues from step 11.

TABLE 1 Orientation Relation for r₍₀₎ T₁ r₍₀₎ ε {r_(k) |k = 2,6} 0.5r₍₀₎ ε {r_(k) |k = 1,3,5,7} 0.4 r₍₀₎ ε {r_(k) |k = 0,4} 0.3

Step 11

Directionality is not yet found, therefore in step 11 the three smallestgradient ratios are checked to determine if they are neighbours and ifthe smallest gradient ratio is in the middle. In that case a stillhigher threshold value compared with the threshold value used in Step 3can be used to check the directionality. This means that a moreuncertain examination is performed. Step 11 uses the values of thresholdT₂ defined in Table 2, below. Then, if the directionalitiescorresponding to the second r₍₁₎ and the third gradient ratios r₍₂₎ arethe closest neighbours for the directionality corresponding to the firstgradient ratio r₍₀₎ and r₍₀₎<T₂ as defined in Table 2, the block isclassified as corresponding to class Dk₍₀₎ and the method continues fromstep 12. Otherwise the method continues from step 13.

TABLE 2 Orientation Relation for r₍₀₎ T₂ r₍₀₎ ε {r_(k) |k = 2,6} 0.6r₍₀₎ ε {r_(k) |k = 1,3,5,7} 0.5 r₍₀₎ ε {r_(k) |k = 0,4} 0.4

Step 12

Step 12 performs a check that classification is really based on an edgein the image with a certain orientation rather than texture. Step 12uses the values of threshold T₃ defined in Table 3, below, In Table 3values for only two possible block sizes (8×8, 4×4) are shown, but inpractical embodiments other block sizes can also exist, whereinrespective values for T₃ are defined, In step 12 the minimum gradientvalue g_(min)=min{g_(k)} is examined. Depending on the classificationand the size of the block, the threshold T₃ is chosen from Table 3. Ifg_(min)≦T₃ the initial classification process terminates. Otherwise themethod continues from step 13.

TABLE 3 Classification of the Block T₃ for 4 × 4 Block T₃ for 8 × 8Block D2 and D6 9.0 7.0 D1, D3, D5 and D7 11.5 9.0 D0, D4 14.0 11.0

Step 13

Step 13 performs a check whether texture is smooth or coarse. Themaximum gradient value g_(max) is compared with 10.0. If g_(max)≦10.0the block is classified as D9. Otherwise, the block is classified as D10Step 13 is not necessarily needed, if both smooth and coarse texture aremapped into the same context class.

Next the selection 21 of a suitable prediction method is performed forthe current block C. in a preferred embodiment of the invention, theselection phase is preceded by a mapping phase. The purpose of themapping is to reduce the memory consumption of the implementation. Someof the directionality classes can be mapped together. The classesresulting from the mapping phase are called context classes and they arereferred to with references C1-C6. In the preferred embodiment of theinvention, the diagonal classes are combined to two alternative classes,one for bottom-left to top-right diagonality and the other for top-leftto bottom-right diagonality.

Mild and steep diagonal classes D5, D6 and D7 are mapped to the firstdiagonal context class C4. Similarly, classes D1, D2 and D3 are mappedto the second diagonal context class C2. Further, the smooth textureclass D9 and coarse texture class D10 are mapped together to producetexture context class C6. This mapping is illustrated in FIG. 4.

In addition to the 6 context classes C1-C6 there is one further contextclass C0 used for “Non-Intra” blocks. In general, a “Non-Intra” block isa block that does not exist, i.e. when block C is at an image boundary.If the prediction is implemented in such a way that only intra-codedblocks are used as a reference, the definition of a “Non-Intra” block isextended to those blocks that are not intra-coded.

In the preferred embodiment of the invention there are a total of 13different prediction methods, which are depicted in FIGS. 5 a-5 p for8×8 blocks. Prediction methods for other block sizes and context.classes can be derived in a similar fashion. In each case, prediction isperformed in a causal manner, using neighbouring reconstructedintra-coded blocks L, U, UL, UR as a reference. The region used forprediction depends on the prediction method, as depicted in FIGS. 3 aand 3 b, where block C is the current block to be coded. In the case ofprediction methods P1-P12, the region from which blocks may be used forprediction is the area covered by four neighbouring blocks L, UL, U andR as shown in FIG. 3 b. For prediction method P13, this region islarger, as depicted in FIG. 3 c. It should be appreciated that in otherembodiments of the invention, the number of prediction methods, theblocks used as prediction references, as well as the pixels within thoseblocks used to perform prediction, may vary.

In an advantageous embodiment of the method according to the invention,a subset of prediction methods for each context class combination isdefined and the prediction methods are prioritized (ranked) in eachsubset. Then, the prediction method used to predict the content of thecurrent block C is selected from a subset of prediction methods. Theprediction methods within a subset differ from each other and correspondto those prediction methods that are most likely to provide an accurateprediction for block C, in the event of particular classifications beingobtained for neighbouring blocks like L and U. One advantageousdefinition for the subsets is presented in Table 4 below.

Effectively, the results of context classification for the firstneighbouring block L and second neighbouring block U are combined, i.e.both taken into consideration when selecting a prediction method forblock C. The subset of prediction methods is selected from Table 4according to the context information of the neighbouring blocks L, U.Each row of Table 4 defines the prediction method subset for a certainpair of context classes for neighbouring blocks L, U and the priority(rank) of the prediction methods in the subset. Ranking is used tosimplify the context-dependent signalling of the prediction methods, asdescribed later in this description. For example, if the firstneighbouring block L is classified into context class C2 and the secondneighbouring block U is classified into context class C4, the subset forthis combination comprises prediction methods P1, P9, P5, P13, P7 and P6(in ranking order). The prediction estimator 3 further selects the mostappropriate prediction method from this subset, as detailed later inthis description,

TABLE 4 L Rank of Prediction Methods Class U Class Rank 1 Rank 2 Rank 3Rank 4 Rank 5 Rank 6 C0 C0 P1 P5 P11 P9 P8 P4 C1 P1 P9 P5 P8 P2 P13 C2P1 P5 P2 P13 P11 P3 C3 P5 P13 P1 P9 P12 P7 C4 P1 P8 P5 P9 P6 P7 C5 P1 P8P5 P3 P2 P10 C6 P1 P5 P9 P13 P8 P12 C1 C0 P9 P1 P2 P13 P8 P10 C1 P9 P1P13 P2 P5 P10 C2 P9 P1 P2 P5 P3 P11 C3 P9 P5 P1 P13 P4 P11 C4 P9 P1 P13P5 P3 P7 C5 P9 P1 P13 P2 P8 P10 C6 P9 P1 P13 P5 P11 P2 C2 C0 P1 P9 P10P11 P12 P7 C1 P9 P1 P10 P5 P11 P2 C2 P1 P11 P10 P2 P3 P12 C3 P5 P1 P11P9 P4 P13 C4 P1 P9 P5 P13 P7 P6 C5 P1 P9 P10 P11 P2 P7 C6 P1 P11 P9 P5P12 P10 C3 C0 P5 P1 P12 P9 P13 P7 C1 P1 P9 P5 P13 P3 P11 C2 P5 P1 P9 P4P13 P3 C3 P5 P1 P13 P9 P12 P11 C4 P1 P5 P9 P6 P13 P7 C5 P1 P5 P9 P13 P3P6 C6 P5 P1 P11 P13 P9 P12 C4 C0 P1 P9 P7 P8 P6 P13 C1 P9 P1 P5 P13 P8P7 C2 P1 P5 P9 P13 P7 P11 C3 P5 P1 P13 P9 P7 P11 C4 P1 P13 P7 P9 P5 P8C5 P1 P7 P9 P13 P8 P4 C6 P1 P9 P13 P5 P7 P8 C5 C0 P1 P9 P10 P11 P6 P7 C1P1 P9 P5 P8 P10 P13 C2 P1 P5 P11 P4 P13 P10 C3 P5 P1 P13 P10 P6 P4 C4 P1P8 P5 P13 P10 P7 C5 P1 P9 P3 P5 P8 P13 C6 P1 P9 P5 P13 P10 P8 C6 C0 P1P9 P2 P5 P6 P11 C1 P9 P1 P5 P13 P2 P3 C2 P1 P9 P5 P13 P2 P11 C3 P5 P1 P9P13 P12 P11 C4 P1 P9 P5 P10 P7 P13 C5 P1 P9 P13 P2 P5 P7 C6 P1 P9 P5 P13P11 P12

In the following, the defined prediction methods are described in moredetail.

Prediction Method P1

Prediction method P1 predicts the average pixel value of block C fromthe average pixel values of blocks L, UL, U and UR. The average pixelvalues dL, dUL and dU of the reconstructed blocks L, UL, and U arecalculated as the integer division defined as $\begin{matrix}{d = {\left( {{\sum\limits_{{x = 0},{y = 0}}^{{N - 1},{N - 1}}{I\left( {x,y} \right)}} + {\frac{1}{2}N^{2}}} \right)//N^{2}}} & (3)\end{matrix}$where N is the size of the block, I(x,y) represents the pixel intensityvalues and “//” denotes division with truncation to integer value. Theaverage pixel value dC of block C is predicted according to followingset of rules (which are written below in the form of pseudo-code):if all blocks L, U and UL exist, then

-   -   if dL=dU=dUL then dC=dUL    -   else if dUL=dU then dC=dL    -   else if dUL=dL then dC=dU    -   else if dL=dU then        -   if chrominance prediction then dC=dL        -   else if |dUL−dL|<4 then dC=s(dL+dU−dUL)        -   else dC=dL    -   else if dUL<dL<dU then dC=dU    -   else if dUL<dU <dL then dC=dL    -   else if dU<dL<dUL then dC=dU    -   else if dL<dU<dUL then dC=dL    -   else if dL<dUL<dU OR dU<dUL<dL then dC=s(dL+dU−dUL)    -   else if blocks L and U exist then dC=(dL+dU+1)//2    -   else if blocks L and UL exist then dC=dL    -   else if blocks U and UL exist then dC=dU    -   else if block L exists then dC=dL    -   else if block U exists then dC=dU    -   else if block UL exists then dC=dUL    -   else dC=p        where p is a value that is in the middle of the possible pixel        value range, e.g. 128, “//” denotes division with truncation and        s is a clipping function that restricts the values to the        possible range of pixel values, e.g. between 0 and 255 in a        system that uses an 8-bit representation of        luminance/chrominance values. As a result, the prediction block        for C is filled with pixels having a constant value given by dC.        Prediction method P1 is illustrated in FIG. 5 a.

Prediction Method P2-P4

Prediction methods P2 through P4 predict diagonal shapes in block C byextending image details from the upper right direction into block C.Prediction is performed by copying reference pixel values at theboundaries of blocks U and UR into block C, as depicted in FIGS. 5 b, 5c, 5 d, respectively. Reference pixels that are marked in grey areconnected to one or more predicted pixels. The connection is marked asline with dots to indicate connected predicted pixels, the value of thereference pixel is copied to all connected predicted pixels.

Since one or more reference blocks might be unavailable, i.e. theircontext class may be C0, prediction is performed according to followingrules.

Rule 1

If both blocks, U and UR, are classified into one of classes C1-C6,pixel prediction is performed as shown in FIGS. 5 b, 5 c and 5 drespectively. For prediction method P2 (FIG. 5 b), pixels without anycorresponding reference pixel in block UR are advantageously allocatedthe value of the rightmost reference pixel in block UR.

Rule 2

If block U is classified into one of classes C1-C6 and block UR isclassified as C0, pixel prediction is performed as shown in FIGS. 5 b, 5c and 5 d for pixels that have a reference pixel in block U. The rest ofthe pixels are advantageously set to the value of the pixel in the lowerright corner of the reference block U.

Rule 3

If block U is classified as C0, the current block C is advantageouslyfilled with pixels having a constant value that is substantially in themiddle of the possible dynamic range of pixel values, e.g. 128 (in asystem, that uses an 8-bit representation of luminance/chrominancevalues).

Prediction Method P5 and P9

Prediction methods P5 (FIG. 5 e) and P9 (FIG. 5 i) predict vertical andhorizontal shapes in the current block C by extending image details intothe current block C, either from above or from the left. Depending onthe selected method (P5 or P9), the reference pixel values at theboundary of either block U or L are copied to the current block C asdepicted in FIGS. 5 e and 5 i.

If the context class of the reference block is C0 then the current blockC is advantageously filled with pixels having a constant value that issubstantially in the middle of the possible dynamic range of pixelvalues, e.g. 128 (in a system, that uses an 8-bit representation ofluminance/chrominance values).

Prediction Method P6, P7 and P8

Prediction methods P6, P7 and P8 predict diagonal shapes in the currentblock C by extending image details from the upper left direction intothe current block C as depicted in FIGS. 5 f, 5 g and 5 h, respectively.Prediction is performed by copying reference pixel values at theboundaries of blocks L, UL and U into the current block C according tofollowing rules.

Rule 1

If all blocks L, UL and U are classified into one of classes C1-C6, thepixel prediction for the current block C is performed as illustrated inFIGS. 5 f, 5 g and 5 h.

Rule 2

If blocks UL and U are classified into one of classes C1-C6 and block Lis classified as C0, pixel prediction for the current block C isperformed as shown in FIGS. 5 f, 5 g and 5 h for those pixels of thecurrent block C that have a reference pixel in blocks UL and L. Theremaining pixels in the current block C are advantageously assigned thevalue of the pixel in the lower left corner of the reference pixel areain block UL.

Rule 3

If blocks L and UL are classified into one of classes C1-C6 and block Uis classified as C0, pixel prediction for the current block C isperformed as shown in FIGS. 5 f, 5 g and 5 h for those pixels of thecurrent block C that have a reference pixel in blocks L and UL. Theremaining pixels in the current block C are advantageously assigned thevalue of the pixel in the upper right corner of the reference pixel areain block UL.

Rule 4

If blocks L and U are classified into one of classes C1-C6 and block ULis classified as C0, pixel prediction for the current block C isperformed as shown in FIGS. 5 f, 5 g and 5 h for those pixels of thecurrent block C that have a reference pixel in blocks L and U. Pixelswith reference pixel in block UL are predicted as shown in FIGS. 5 n, 5o and 5 p. In case of method P7, the predicted pixel value is theaverage of the two reference pixel values rounded to the nearest integervalue, as indicated in FIG. 50.

Rule 5

If block L is classified into one of classes C1-C6 and blocks UL and Uare classified as C0, pixel prediction for the current block C isperformed as shown in FIGS. 5 f, 5 g and 5 h for those pixels of thecurrent block C that have a reference pixel in block L. The remainingpixels in the current block C are advantageously assigned the value ofthe pixel in the upper right corner of the reference pixel area in blockL.

Rule 6

If block UL is classified into one of classes C1-C6 and blocks L and Uare classified as C0, pixel prediction for the current block C isperformed as shown in FIGS. 5 f, 5 g and 5 h for those pixels of thecurrent block C that have a reference pixel in blocks UL. Pixels of thecurrent block C that have a reference pixel in block L areadvantageously assigned the value of the lower/left reference pixel inblock UL. Pixels of the current block C that have a reference pixel inblock U are assigned the value of the upper/right reference pixel inblock UL.

Rule 7

If block U is classified into one of classes C1-C6 and blocks L and ULare classified as C0, pixel prediction for the current block C isperformed as shown in FIGS. 5 f, 5 g and 5 h for those pixels of thecurrent block C that have a reference pixel in block U. The remainingpixels of the current block C are advantageously assigned the value ofthe pixel in the lower left corner of the reference pixel area in blockU.

Rule 8

If all blocks L, UL and L are classified as C0, the current block C isadvantageously filled with pixels having a constant value that issubstantially in the middle of the possible dynamic range of pixelvalues, e.g. 128 (in a system, that uses an 8-bit representation ofluminance/chrominance values).

Prediction Method P10, P11 and P12

Prediction methods P10 through P12 predict diagonal shapes in thecurrent block C by extending image details from the left into thecurrent block C as depicted in FIGS. 5 j, 5 k and 5 l, respectively.Prediction is performed by copying reference pixel values at theboundary of blocks L into the current block C according to followingrules.

Rule 1

If block L is classified into one of classes C1-C6, the pixel predictionfor the current block C is performed as illustrated in FIGS. 5 j, 5 kand 5 l. Pixels of the current block C without reference pixel in blockL are advantageously filled with the value of the pixel in the lowerright corner of the reference pixel area.

Rule 2

If block L is classified as C0, the current block C is advantageouslyfilled with pixels having a constant value that is substantially in themiddle of the possible range of pixel values, e.g. 128 (in a system,that uses an 8-bit representation of luminance/chrominance values).

Prediction method P13

Prediction method P13 predicts the content of the current block C fromthe neighbouring image content by examining if there exists a range ofpixels having values which substantially corresponds to the pixel valuesof the current block C. The prediction of the current block C isperformed by copying reconstructed pixel values from a reference block Bthat is inside a search range SR as depicted in FIG. 5 m. Search rangeSR is defined by lists of horizontal (x) and vertical (y) displacements.Each pair of horizontal displacement and corresponding verticaldisplacement values (x, y) defines a displacement vector between thecoordinates of upper left corner of the current block C and upper leftcorner of the reference block B. Prediction is allowed only for thosedisplacements corresponding to reference block B that is completelyinside the reconstructed part of the frame. Examples of displacementpairs using 512 displacements for 8×8 blocks are presented in Tables 9 aand 9 b. In this example the scanning order of the tables is fromtop-left to bottom-right row by row. In alternative embodiments of theinvention, the search range may be different from that depicted in FIG.5 m and/or the displacement between the reference block B and thecurrent block may be defined differently.

The list of allowed displacements is known to both the encoder and thedecoder, allowing context-dependent signalling of the selected referenceblock location.

There are many alternative ways to select the prediction method from asubset of prediction methods. For example, a cost function can bedefined in order to evaluate the effectiveness of the differentprediction methods of the subset to be used, The cost function may becalculated on the basis of information concerning the error incurredwhen predicting a current block C using a particular prediction method.This error denotes differences between actual pixel values andreconstructed pixel values. Typically, the error values for each pixelin the current block C are squared and summed together to produce asquared error measure for the whole block. The cost function may alsocomprise information concerning the number of bits, i.e. the bit rateneeded to transfer the information to the receiver. The elements of thecost function, particularly the bit rate, can also be weighted toemphasize them. One example of a cost function is:Cx=D+λR,  (4)where cost Cx is defined as a weighted sum of distortion D and rate Rassociated with each of the prediction methods and λ is the weightingfactor. If the transmission system is band limited, the weight value istypically larger than if the bandwidth is wider. The values for formula(4) are calculated for different prediction methods and preferably thatprediction method which yields the smallest value for the cost functionis selected.

Additionally, the prediction error information can also be coded priorto transmission to the receiver. Advantageously, there is a subset ofcoding methods defined for each prediction method. Specifically, thecoding method could be chosen to minimise the number of bits required toencode the prediction error. For example, the effectiveness (bit rate)of the coding method is examined.

If the prediction error is relatively small, it may not be necessary totransmit the prediction error information at all.

Referring once more to FIGS. 1 and 2, once a suitable prediction methodhas been selected for predicting a current block C, the predictionestimator 3 performs spatial prediction 22 according to the selectedprediction method. The prediction estimator 3 directs the reconstructedblock to summer 4 where the reconstructed block is subtracted from theactual contents of the current block C to produce prediction errorinformation for the current block.

The encoder 1 sends 23 the information about the selected predictionmethod to the multiplexer 9, which is accompanied by displacementinformation if method P13 is used. Advantageously, the selectedprediction method is indicated by its rank in the subset of predictionmethods appropriate for the particular combination of neighbouringblocks (U, L) in question. Encoding of the information is advantageouslyperformed using variable length coding.

The information is further transmitted to the receiver 10, where thedemultiplexer 11 demultiplexes the received information. In the receiver10 the prediction information is directed to the predictor 16. Thereceiver 10 also comprises a frame memory 14, where the previouslyreconstructed blocks are saved. When a new coded block arrives at thereceiver, the predictor 16 performs the classifying steps for theneighbouring blocks U, L of the received current block C to classifythem into directionality classes, as previously described. Then thepredictor 16 carries out the mapping of classification information intocontext classes C1-C6. After that the predictor 16 also examines therank of the prediction method. The receiver 10 contains the informationof the Table 4 and 5, wherein the predictor 16 can determine the correctprediction method according to the context class combination and therank.

When the prediction method has been determined, the predictor 16 canreconstruct the current block C and save it to the frame memory 14. In asituation where prediction error information is also received, thatinformation is first decoded in the decoder 12, if necessary, andcombined with the pixel values of the reconstructed block C. Now thecurrent block C is ready to be directed to the output 15 of thereceiver.

If the prediction method of the current block C is P13, thereconstruction of current block C is performed in a slightly differentmanner. In this case, the receiver 10 also has to decode thedisplacement information, wherein the displacement information is usedto copy the pixel values of the current block C from previouslyreconstructed pixel values in the frame memory 14.

Signalling of the prediction method is advantageously based on thecontext-dependent codes defined in Table 5. After selecting theappropriate prediction method, the encoder 1 sends a variable lengthcodeword that corresponds to the rank of the selected prediction methodin the context-dependent subset. Advantageous examples of variablelength codewords representing each prediction method rank are listed inTable 5. For example, if the first neighbouring block L is classifiedinto context class C3 and the second neighbouring block U is classifiedinto context class C1, and the prediction method P9 is selected from thesubset of the prediction methods for this combination, the respectiverank is 2. Then, the codeword which corresponds this rank is “01”.

TABLE 5 Rank Code Length 1   1 1 2  01 2 3 0000 4 4 0001 4 5 0010 4 60011 4

The receiver 10 is aware of the contents of Table 4, i.e. it knows whichprediction method corresponds to each of the ranks in every possiblecontext (combination of classes for the neighbouring blocks L and U).Since the receiver 10 can derive the same context information as theprediction estimator 3, receiver 10 can associate the rank representedby the received codeword to correct prediction method and perform thespatial prediction for block C according to the method.

In an advantageous embodiment of the invention the signalling ofhorizontal and vertical displacements associated with prediction methodP13 is performed as follows:

Step 1

Those pairs of horizontal and vertical displacements (X(i), Y(i)) thatcorrespond to reference blocks B lying partially or entirely outside theframe are eliminated from the ordered list given in Tables 9a, 9b. Thenumber of valid pairs is denoted by Nv and the ordered list of validpairs which are retained after the elimination is denoted by Lv.

Step 2

The rank r (which is one of 1, 2, . . . , Nv) corresponding to thechosen block B within the list Lv created in Step 1 is calculated.

Step 3

Based on the value of rank r determined in Step 1 the value index₁ iscalculated according to Table 6.

Step 4

The value index₂=r−OffsetLow(index₁) is calculated using the valueslisted in Table 6.

TABLE 6 OffsetLow OffsetHigh AuxLength Range for rank r index₁ (index₁)(index₁) (index₁) 1, . . ., 2 1 1 2 1 3, . . ., 4 2 3 4 1 5, . . ., 6 35 6 1 7, . . ., 8 4 7 8 1 9, . . ., 12 5 9 12 2 13, . . ., 16 6 13 16 217, . . ., 24 7 17 24 3 25, . . ., 32 8 25 32 3 33, . . ., 48 9 33 48 449, . . ., 64 10 49 64 4 65, . . ., 98 11 65 96 5 97, . . ., 128 12 97128 5 129, . . ., 192 13 129 192 6 193, . . ., 256 14 193 256 6 257, . .., 384 15 257 384 7 385, . . ., 512 16 385 512 7

Step 5

Next, a variable bits is calculated as follows. IfNv<OffsetHigh(index₁), the value for the variable bits is computedadvantageously using the formula bits=[log2(1+Nv−OffsetLow(index1))],where [x] denotes the nearest integer≧x. Otherwise,bits=AuxLength(index1).

Step 6

Depending on the value of Nv the variable whose sub-script is index₁ isencoded using the corresponding Variable Length Coding given in Table 7and Table 8. This codeword is transmitted to the decoder, which isillustrated with block CW1 in FIG. 6.

Step 7

If the variable bits is nonzero the binary representation of index2 isencoded using a number of bits corresponding to the value of variablebits and this codeword is transmitted to the receiver, which isillustrated with block CW2 in FIG. 6.

TABLE 7 N_(v) in range N_(v) in range N_(v) in range 1, . . ., 16 17, .. ., 32 33, . . ., 64 VLC_(A) VLC_(B) VLC_(C) Symbol Length Code SymbolLength Code Symbol Length Code A₁ 2 11 B₁ 1   1 C₁ 2  11 A₂ 3 001  B₂ 2  01 C₂ 3  101 A₃ 2 10 B₃ 4  0011 C₃ 4 0011 A₄ 4 0001  B₄ 4  0010 C₄ 500001  A₅ 2 01 B₅ 5 00011 C₅ 3  100 A₆ 4 0000  B₆ 5 00010 C₆ 4 0010 B₇ 500001 C₇ 4 0001 B₅ 5 00000 C₈ 5 00000  C₉ 3  011 C₁₀ 3  010

TABLE 8 N_(v) in range N_(v) in range N_(v) in range 65, . . ., 128 129,. . ., 256 257, . . ., 512 VLC_(D) VLC_(E) VLC_(F) Symbol Length CodeSymbol Length Code Symbol Length Code D₁ 2   11 E₁ 2  11 F₁ 3  111 D₂ 3 101 E₂ 3  101 F₂ 4 1011 D₃ 5 00001 E₃ 4 0111 F₃ 4 1010 D₄ 5 00000 E₄ 500011  F₄ 6 000001  D₅ 4  0111 E₅ 4 0110 F₅ 4 1001 D₆ 4  0110 E₆ 500010  F₆ 5 00001  D₇ 3  100 E₇ 4 0101 F₇ 4 1000 D₈ 4  101 E₈ 4 0100 F₈4 0111 D₉ 4  0100 E₉ 3  100 F₉ 4 0110 D₁₀ 4  0011 E₁₀ 4 0011 F₁₀ 4 0101D₁₁ 4  0010 E₁₁ 4 0010 F₁₁ 4 0100 D₁₂ 4  0001 E₁₂ 5 00001  F₁₂ 4 0011E₁₃ 6 000001  F₁₃ 3  110 E₁₄ 6 000000  F₁₄ 4 0010 F₁₅ 4 0001 F₁₆ 6000000 

TABLE 9a X[512] = −8 −8 −8 −1 −10 −8 0 1 −16 −9 −8 −8 −18 −8 −12 −11 −14−11 −19 −15 −10 −10 −9 −16 −9 −9 −14 −13 −13 −2 −12 −11 −8 3 −15 0 −19−15 −3 0 −10 11 2 −13 −11 0 −12 −19 1 −18 −17 −11 −10 −14 −1 18 −7 −5−12 −10 −8 −13 −9 −9 0 −14 21 5 −3 10 −10 −15 −14 −13 19 −11 −10 −11 140 −19 −13 −16 4 −12 −4 −16 3 12 −13 −19 7 −19 −13 −4 −15 −10 1 −12 −17 00 −16 −16 −15 −11 1 −16 −18 −12 −8− 18 −15 −6 0 −13 −18 −2 16 17 −12 −92 8 −12 16 18 −9 −19 −19 4 −11 −18 −18 0 15 15 19 −6 −14 16 14 −18 8 −16−17 13 0 −1 −12 16 −17 −8 −16 −16 −1 −15 −1 −18 −17 5 6 4 8 5 −11 −16 −2−7 2 −14 4 −17 −13 −2 13 −5 −18 −19 −17 −9 −6 −16 13 −15 0 13 −19 6 −5−14 −5 1 −19 −1 −17 −12 −13 −6 12 −8 −13 −14 3 17 −14 −14 −11 12 −1 5−11 −2 −4 3 −1 −2 5 −9 1 −12 14 9 1 −9 20 −19 18 −17 −1 −12 −3 4 −17 13−12 −17 −5 −4 −17 −4 −8 9 1 −15 8 7 −1 13 8 −3 −6 −3 −12 −16 −13 −5 16−13 15 −19 −15 2 12 11 −15 14 −15 −5 7 11 −15 −4 20 −7 4 17 15 −14 3 −10−14 −15 −15 14 1 −11 12 10 14 5 13 −9 −3 −12 17 −17 −11 9 −3 −1 3 11 −18−18 −8 −3 7 −4 −13 −14 −17 8 8 −10 −6 16 −7 19 −8 1 −10 19 6 10 4 13 203 8 −18 4 15 1 −8 −11 −2 −6 3 6 −14 9 −16 −2 −14 −8 6 −7 −17 7 6 16 −135 5 4 −10 −3 −13 10 17 2 6 11 −13 −9 −16 −14 −7 −2 6 −18 9 −8 −11 −7 −78 5 9 −3 6 −12 −7 −4 12 12 −8 −6 −9 −11 12 −5 12 −11 4 −14 8 10 5 19 −4−12 −2 −3 −4 7 12 14 15 −6 7 7 4 11 11 −18 −6 −7 18 10 −10 −10 2 −1 −10−8 2 −9 13 11 11 17 15 13 2 10 −7 −10 14 −2 4 5 12 −3 −4 17 −5 7 10 13 36 −6 −6 −11 9 9 2 −9 −12 3 −9 −10 6 3 14 11 9 8 −5 −7 10 7 −12 14 1 5−13 2 −11 18 11 12 −4 −5 −9 −10 −9 16 7 15 9 9 10 2 18 10 8 10 15 −15 3−5 −9 7 −2 2 9 6 11 −10

TABLE 9b Y[512] = −1 −2 −3 −8 −2 0 −8 −8 0 −2 −4 −6 0 −5 0 −2 0 0 −1 0−1 0 −4 −1 −1 0 −3 −2 0 −8 −2 −1 −7 −8 −2 −14 0 −4 −8 −18 −7 −8 −8 −3 −5−16 −1 −4 −19 −13 0 −8 −6 −2 −19 −8 −8 −8 −9 −8 −1 −5 −3 −15 −6 −8 −5 −9−8 −3 −5 −8 −6 −10 −3 −5 −4 −8 −12 −7 −10 −15 −8 −4 −8 −2 −9 −9 −5 −10−8 −3 −11 −9 −6 −8 −11 −7 −3 −10 −13 −8 −3 −3 −6 −16 −12 −3 −3 −9 −4 −1−8 −9 −7 −5 −10 −8 −8 −5 −7 −9 −8 −6 −9 −13 −6 −2 −5 −9 −9 −1 −10 −11−16 −8 −9 −9 −4 −12 −10 −4 −9 −5 −4 −10 −17 −16 −19 −11 −6 −19 −9 −10 −9−16 −12 −8 −8 −19 −8 −17 −19 −10 −7 −11 −14 −19 −10 −1 −19 −2 −8 −9 −11−19 −7 −8 −1 −8 −19 −7 −16 −8 −19 −9 −11 −9 −10 −11 −12 −18 −6 −11 −11−10 −14 −10 −19 −18 −18 −10 −16 −12 −5 −7 −12 −8 −18 −17 −15 −12 −19 −18−10 −11 −9 −10 −13 −13 −11 −8 −12 −15 −9 −9 −10 −10 −17 −12 −16 −12 −14−8 −8 −7 −9 −17 −12 −12 −16 −16 −9 −11 −17 −19 −14 −18 −16 −12 −14 −15−18 −6 −4 −17 −10 −9 −9 −12 −14 −12 −10 −19 −12 −17 −7 −11 −12 −16 −9−13 −8 −9 −16 −14 −10 −13 −11 −14 −12 −10 −13 −16 −10 −19 −13 −12 −12−15 −17 −16 −10 −17 −10 −5 −16 −18 −18 −13 −19 −9 −6 −2 −17 −19 −11 −10−15 −15 −13 −14 −18 −19 −17 −15 −13 −8 −14 −14 −11 −12 −14 −11 −13 −14−10 −10 −10 −9 −14 −12 −17 −10 −18 −13 −12 −17 −18 −14 −10 −14 −19 −9−12 −10 −11 −9 −9 −16 −14 −13 −16 −12 −10 −9 −14 −12 −15 −13 −16 −12 −18−17 −13 −13 −16 −12 −15 −17 −11 −17 −15 −13 −15 −17 −15 −11 −15 −17 −11−14 −14 −14 −14 −15 −13 −16 −18 −17 −16 −15 −17 −14 −15 −17 −13 −19 −13−11 −16 −16 −16 −11 −15 −15 −12 −9 −13 −18 −16 −13 −18 −17 −10 −12 −11−10 −12 −9 −15 −13 −14 −15 −17 −11 −18 −9 −13 −14 −15 −11 −11 −15 −11−17 −16 −12 −15 −18 −11 −14 −18 −13 −18 −9 −13 −17 −14 −12 −14 −19 −13−15 −10 −9 −12 −19 −17 −15 −12 −14 −16 −15 −15 −14 −11 −11 −11 −14 −18−10 −10 −11 −13 −15 −18 −16 −15 −11 −11 −12 −11 −11 −16 −11 −10 −12 −13−14 −14 −14 −19 −16 −13 −9 −18 −12 −13 −15 −15 −13 −18 −19 −18 −17 −17−13 −13 −13 −18

Since the decoder can derive the ordered list of valid displacementvectors, it can associate the rank represented by the received codewordwith the correct displacement vector.

The block carrying out prediction method according to the invention isparticularly advantageously implemented in a digital signal processor ora corresponding general purpose device suited to processing digitalsignals, which can be programmed to apply predetermined processingfunctions to signals received as input data. The measures according tothe invention can be carried out in a separate signal processor or theycan be part of the operation of such a signal processor which alsocontains other arrangements for signal processing.

A storage medium can be used for storing a software program comprisingmachine executable steps for performing the method according to theinvention. In an advantageous embodiment of the invention the softwareprogram can be read from the storage medium to a device comprisingprogrammable means, e.g. a processor, for performing the method of theinvention.

A mobile terminal 24 intended for use as a portable videotelecommunications device and applying the method according to theinvention comprises advantageously at least display means 25 fordisplaying images, audio means 26 for capturing and reproducing audioinformation, a keyboard 27 for inputting e.g. user commands, a radiopart 28 for communicating with mobile network, processing means 29 forcontrolling the operation of the device, memory means 30 for storinginformation, and preferably a camera 31 for taking images.

The present invention is not solely restricted to the above presentedembodiments, but it can be modified within the scope of the appendedclaims.

1. A method for encoding a digital image in a block-based manner, inwhich a spatial prediction for a block is performed to reduce amount ofinformation to be transmitted, wherein the method comprises: examiningpixel values of a neighbouring block of a block to be predicted todetermine a classification for the neighbouring block according to theimage contents of said neighbouring block; selecting a prediction methodfor the block to be predicted on the basis of said classification; andforming a spatial prediction for the block to be predicted using theselected prediction method.
 2. A method according to claim 1, whereinthe classification for a neighbouring block is determined on the basisof directionality in the image contents of the neighbouring block.
 3. Amethod according to claim 2, wherein the directionality in the imagecontents of the neighbouring block is determined by calculating at leastone gradient value (g_(k)) on the basis of pixel values of theneighbouring block.
 4. A method according to claim 3, wherein gradientvalues (g_(k)) are calculated with the following formula:$\begin{matrix}{{g_{0} = {\frac{1}{N\left( {N - 1} \right)}{\max\left( {1,{\sum\limits_{y = 0}^{N - 1}{\sum\limits_{x = 0}^{N - 2}{{{I\left( {x,y} \right)} - {I\left( {{x + 1},y} \right)}}}}}} \right)}}}{g_{1} = {\frac{1}{\left( {N - 1} \right)^{2}\max}\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 1}{{{I\left( {x,y} \right)} - {\frac{1}{2}\left( {{I\left( {{x - 1},y} \right)} + {I\left( {{x - 1},{y + 1}} \right)}} \right)}}}}}} \right)}}{g_{2} = {\frac{1}{\left( {N - 1} \right)^{2}}\max\quad\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 1}{{{I\left( {x,y} \right)} - {I\left( {{x - 1},{y + 1}} \right)}}}}}} \right)}}{g_{3} = {\frac{1}{\left( {N - 1} \right)^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 1}{{{I\left( {x,y} \right)} - {\frac{1}{2}\left( {{I\left( {{x - 1},{y + 1}} \right)} + {I\left( {x,{y + 1}} \right)}} \right)}}}}}} \right)}}}{g_{4} = {\frac{1}{{N\left( {N - 1} \right)}^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 1}{{{I\left( {x,y} \right)} - {I\left( {x,{y + 1}} \right)}}}}}} \right)}}}{g_{5} = {\frac{1}{\left( {N - 1} \right)^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 2}{{{I\left( {x,y} \right)} - {\frac{1}{2}\left( {{I\left( {x,{y + 1}} \right)} + {I\left( {{x + 1},{y + 1}} \right)}} \right)}}}}}} \right)}}}{g_{6} = {\frac{1}{\left( {N - 1} \right)^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 2}{{{I\left( {x,y} \right)} - {I\left( {{x + 1},{y + 1}} \right)}}}}}} \right)}}}{g_{7} = {\frac{1}{\left( {N - 1} \right)^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}\left. {{\sum\limits_{x = 0}^{N - 2}{{{I\left( {x,y} \right)} - {\frac{1}{2}\left( {{I\left( {{x + 1},y} \right)} + {I\left( {{x + 1},{y + 1}} \right)}} \right.}}}}} \right)}} \right)}}}} & (1)\end{matrix}$ where N is the size of the neighbouring block, I(x,y)represents pixel intensity values, indices x and y refer to coordinatesof a pixel inside the neighbouring block, and k represents edgeorientations.
 5. A method according to claim 4, wherein at least eightdirectionality classes are defined for different edge orientations.
 6. Amethod according to claim 5, wherein the classification comprises afurther 3 non-directional classes corresponding to flat, smooth textureand coarse texture blocks.
 7. A method according to claim 1, furthercomprising defining at least two context classes and performing amapping phase in which the classification for a neighbouring block ismapped into one of said context classes.
 8. A method according to claim1, comprising: determining a classification for at least twoneighbouring blocks of said block to be predicted according to the imagecontents of said neighbouring blocks; defining context classes for saidneighbouring blocks; and selecting a prediction method for the block tobe predicted on the basis of a combination of the defined contextclasses.
 9. A method according to claim 1, comprising defining a costfunction and selecting a prediction method for the block to be predictedby: calculating a value of the cost function for at least two predictionmethods; examining the calculated cost function values to find theminimum value; and selecting the prediction method which produces saidminimum value for the cost function.
 10. A method according to claim 9,wherein the cost function is defined as:Cx=D+λR, where cost Cx is defined as a weighted sum of distortion D andrate R associated with each of the prediction methods and λ is theweighting factor.
 11. A method according to claim 1, further comprising:defining a prediction error on the basis of a prediction formed for theblock to be predicted and the real pixel values of said block to bepredicted; coding the prediction error information; and transmitting thecoded prediction error information.
 12. A storage medium for storing asoftware program comprising machine executable steps for performing themethod according to claim
 1. 13. A method according to claim 1,comprising determining a classification for more than one neighbouringblock of said block to be predicted and selecting a prediction methodfor said block to be predicted on the basis of the classifications forsaid more than one neighbouring block.
 14. A method according to claim 1wherein the selected prediction method extends image details having acertain directionality into the block to be predicted.
 15. A methodaccording to claim 1, wherein said classification is representative ofthe directionality of the image contents of said neighbouring block. 16.A method according to claim 15, further comprising combiningclassifications representative of similar directionalities to formcontext classes representative of said similar directionalities.
 17. Amethod according to claim 1, comprising: determining a classificationfor at least two neighbouring blocks of said block to be predictedaccording to the image contents of said neighbouring blocks; andselecting a sub-set of prediction methods from a set of availableprediction methods on the basis of the classifications of said at leasttwo neighbouring blocks.
 18. A method according to claim 17, furthercomprising: selecting a prediction method for the block to be predictedfrom said sub-set of prediction methods on the basis of theclassifications of said at least two neighbouring blocks; and forming aspatial prediction for the block to be predicted using the selectedprediction method.
 19. A method according to claim 18, furthercomprising providing a signal indicative of the selected predictionmethod.
 20. A method according to claim 18, comprising calculating acost function representative of an error incurred when using aparticular prediction method to form a spatial prediction for the blockto be predicted and selecting the prediction method for the block to bepredicted from said sub-set of prediction methods that yields thesmallest value for the cost function.
 21. A method according to claim20, wherein the cost function includes a measure of an error incurredwhen using a particular prediction method to form a spatial predictionfor the block to be predicted and a measure of an amount of informationrequired to be transmitted to a corresponding decoder when saidparticular prediction method is selected.
 22. A storage medium forstoring a software program comprising machine executable steps forperforming the method according to claim
 13. 23. A device for encoding adigital image in a block-based manner, the device being arranged toperform a spatial prediction for a block to reduce an amount ofinformation to be transmitted, wherein the device comprises: a blockclassifier arranged to examine pixel values of a neighbouring block ablock to be predicted to determine a classification for the neighbouringblock according to the image contents of said neighbouring block; aprediction method selector for selecting a prediction method for theblock to be predicted on the basis of said classification; and aprediction estimator for forming a spatial prediction for the block tobe predicted using the selected prediction method.
 24. A deviceaccording to claim 23, wherein the block classifier is arranged todetermine the classification for a neighbouring block on the basis ofdirectionality in the image contents of the neighbouring block.
 25. Adevice according to claim 24, wherein the block classifier is arrangedto determine the directionality in the image contents of theneighbouring block by calculating at least one gradient value (g_(k)) onthe basis of pixel values of the neighbouring block.
 26. A deviceaccording to claim 25, wherein the block classifier is arranged tocalculate the gradient values (g_(k)) with the following formula:$\begin{matrix}{{g_{0} = {\frac{1}{N\left( {N - 1} \right)}{\max\left( {1,{\sum\limits_{y = 0}^{N - 1}{\sum\limits_{x = 0}^{N - 2}{{{I\left( {x,y} \right)} - {I\left( {{x + 1},y} \right)}}}}}} \right)}}}{g_{1} = {\frac{1}{\left( {N - 1} \right)^{2}\max}\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 1}{{{I\left( {x,y} \right)} - {\frac{1}{2}\left( {{I\left( {{x - 1},y} \right)} + {I\left( {{x - 1},{y + 1}} \right)}} \right)}}}}}} \right)}}{g_{2} = {\frac{1}{\left( {N - 1} \right)^{2}}\max\quad\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 1}{{{I\left( {x,y} \right)} - {I\left( {{x - 1},{y + 1}} \right)}}}}}} \right)}}{g_{3} = {\frac{1}{\left( {N - 1} \right)^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 1}{{{I\left( {x,y} \right)} - {\frac{1}{2}\left( {{I\left( {{x - 1},{y + 1}} \right)} + {I\left( {x,{y + 1}} \right)}} \right)}}}}}} \right)}}}{g_{4} = {\frac{1}{{N\left( {N - 1} \right)}^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 1}{{{I\left( {x,y} \right)} - {I\left( {x,{y + 1}} \right)}}}}}} \right)}}}{g_{5} = {\frac{1}{\left( {N - 1} \right)^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 2}{{{I\left( {x,y} \right)} - {\frac{1}{2}\left( {{I\left( {x,{y + 1}} \right)} + {I\left( {{x + 1},{y + 1}} \right)}} \right)}}}}}} \right)}}}{g_{6} = {\frac{1}{\left( {N - 1} \right)^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}{\sum\limits_{x = 0}^{N - 2}{{{I\left( {x,y} \right)} - {I\left( {{x + 1},{y + 1}} \right)}}}}}} \right)}}}{g_{7} = {\frac{1}{\left( {N - 1} \right)^{2}}{\max\left( {1,{\sum\limits_{y = 0}^{N - 2}\left. {{\sum\limits_{x = 0}^{N - 2}{{{I\left( {x,y} \right)} - {\frac{1}{2}\left( {{I\left( {{x + 1},y} \right)} + {I\left( {{x + 1},{y + 1}} \right)}} \right.}}}}} \right)}} \right)}}}} & (1)\end{matrix}$ where N is the size of the neighbouring block, I(x,y)represent the pixel intensity values, indices x and y refer tocoordinates of pixel inside the neighbouring block, and k representsedge orientations.
 27. A device according to claim 26, wherein at leasteight directionality classes (D0-D7) are defined for different edgeorientations.
 28. A device according to claim 23, wherein theclassification comprises a further 3 non-directional classescorresponding to flat, smooth texture and coarse texture blocks.
 29. Adevice according to claim 23, further comprising a mapping unit arrangedto define at least two context classes and to perform a mapping phase,in which the classification for a neighbouring block is mapped into oneof said context classes.
 30. A device according to claim 23, wherein theblock classifier is arranged to perform a classification for at leasttwo neighbouring blocks of said block to be predicted according to theimage contents of said neighbouring blocks, the mapping unit is arrangedto define context classes for said neighbouring blocks and theprediction method selector is arranged to select a prediction method forthe block to be predicted on the basis of a combination of the definedcontext classes.
 31. A device according to claim 23, wherein theprediction method selector is arranged to: calculate a value of a costfunction for at least two prediction methods; examine the calculatedcost function values to find the minimum value, and select theprediction method which produces said minimum value for the costfunction.
 32. A method according to claim 31, wherein the cost functionis defined as:Cx=D+λR, where cost Cx is defined as a weighted sum of distortion D andrate R associated with each of the prediction methods and λ is theweighting factor.
 33. A device according to claim 23, further comprisingmeans for defining a prediction error on the basis of a predictionformed for block to be predicted and the real pixel values of said blockto be predicted, means for coding the prediction error information, andmeans for transmitting the coded prediction error information.
 34. Anencoder for encoding a digital image in a block-based manner, theencoder being arranged to perform a spatial prediction for a block toreduce an amount of information to be transmitted, wherein the encodercomprises: a block classifier arranged to examine pixel values of aneighbouring block of said block to be predicted to determine aclassification for the neighbouring block according to the imagecontents of said neighbouring block (L, U); a prediction method selectorfor selecting a prediction method for the block to be predicted on thebasis of said classification; and a prediction estimator for forming aspatial prediction for the block to be predicted using the selectedprediction method.
 35. A mobile terminal comprising an encoder accordingto claim
 34. 36. An encoder according to claim 34, wherein the blockclassifier is arranged to determine the classification for aneighbouring block on the basis of directionality in the image contentsof the neighbouring block.
 37. An encoder according to claim 34, whereinthe block classifier is arranged to determine a classification for morethan one neighbouring block of said block to be predicted and to selecta prediction method for said block to be predicted on the basis of theclassifications for said more than one neighbouring block.
 38. Anencoder according to claim 34, wherein the prediction estimator isarranged to form a spatial prediction for the block to be predicted byextending image details having a certain directionality into the blockto be predicted.
 39. An encoder according to claim 34, wherein saidclassification is representative of the directionality of the imagecontents of said neighbouring block.
 40. An encoder according to claim39, wherein the block classifier is arranged to combine classificationsrepresentative of similar directionalities to form context classesrepresentative of said similar directionalities.
 41. An encoderaccording to claim 34, wherein the block classifier is arranged todetermine a classification for at least two neighbouring blocks of saidblock to be predicted according to the image contents of saidneighbouring blocks and the prediction method selector is arranged toselect a sub-set of prediction methods from a set of availableprediction methods on the basis of a combination of the classificationsof said at least two neighbouring blocks.
 42. An encoder according toclaim 41, wherein the prediction method selector is arranged to select aprediction method for the block to be predicted from said sub-set ofprediction methods on the basis of the classifications of said at leasttwo neighbouring blocks and the prediction estimator is arranged to forma spatial prediction for the block to be predicted using the selectedprediction method.
 43. An encoder according to claim 42, furtherarranged to provide a signal indicative of the selected predictionmethod.
 44. An encoder according to claim 42, comprising a cost functioncalculator for calculating a cost function representative of an errorincurred when using a particular prediction method to form a spatialprediction for the block to be predicted and the prediction methodselector is arranged to select the prediction method for the block to bepredicted from said sub-set of prediction methods that yields thesmallest value for the cost function.
 45. An encoder according to claim44, wherein the cost function includes a measure of an error incurredwhen using a particular prediction method to form a spatial predictionfor the block to be predicted and a measure of an amount of informationrequired to be transmitted to a corresponding decoder when saidparticular prediction method is selected.
 46. A decoder decoding adigital image in a block-based manner, the decoder being arranged toperform a spatial prediction for a block to reduce an amount ofinformation to be transmitted, wherein the decoder comprises: a blockclassifier arranged to examine pixel values of a neighbouring block ofsaid block to be predicted to determine a classification for theneighbouring block according to the image contents of said neighbouringblock; a prediction method selector for selecting a prediction methodfor the block to be predicted on the basis of said classification; and aprediction estimator for forming a spatial prediction for the block tobe predicted using the selected prediction method.
 47. A decoderaccording to claim 46, wherein the block classifier is arranged todetermine the classification for a neighbouring block on the basis ofdirectionality in the image contents of the neighbouring block.
 48. Adecoder according to claim 46, wherein the block classifier is arrangedto determine a classification for more than one neighbouring block ofsaid block to be predicted and to select a prediction method for saidblock to be predicted on the basis of the classifications for said morethan one neighbouring block.
 49. A decoder according to claim 46,wherein the prediction estimator is arranged to form a spatialprediction for the block to be predicted by extending image detailshaving a certain directionality into the block to be predicted.
 50. Adecoder according to claim 46, wherein the block classifier is arrangedto determine a classification for at least two neighbouring blocksaccording to the image contents of said neighbouring blocks of saidblock to be predicted according to the image contents of saidneighbouring blocks and the prediction method selector is arranged toselect a sub-set of prediction methods from a set of availableprediction methods on the basis of a combination of the classificationsof said at least two neighbouring blocks.
 51. A decoder according toclaim 50, further arranged to receive a signal indicative of aprediction method in said sub-set of prediction methods wherein theprediction method selector is arranged to select a prediction method forthe block to be predicted from said sub-set of prediction methodsresponsive to said received signal.
 52. A mobile terminal comprising adecoder according to claim
 46. 53. A codec for encoding and decodingdigital images, in a block-based manner, the codec being arranged toperform a spatial prediction for a block to reduce an amount ofinformation to be transmitted, wherein the codec comprises: a blockclassifier arranged to examine pixel values of a neighbouring block ofsaid block to be predicted to determine a classification for theneighbouring block according to the image contents of said neighbouringblock; a prediction method selector for selecting a prediction methodfor the block to be predicted on the basis of said classification; and aprediction estimator for forming a spatial prediction for the block tobe predicted using the selected prediction method.
 54. A method fordecoding a digital image in a block-based manner, in which a spatialprediction for a block is performed to reduce an amount of informationto be transmitted, wherein the method comprises: examining pixel valuesof a neighbouring block of a block to be predicted to determine aclassification for the neighbouring block according to the imagecontents of said neighbouring block; selecting a prediction method to beused in forming a spatial prediction for the block to be predicted onthe basis of said classification; and forming a spatial prediction forthe block to be predicted using the selected prediction method.
 55. Amethod according to claim 54, wherein the classification for aneighbouring block is determined on the basis of directionality in theimage contents of the neighbouring block.
 56. A method according toclaim 54, comprising determining a classification for more than oneneighbouring block of said block to be predicted and selecting aprediction method for said block to be predicted on the basis of theclassifications for said more than one neighbouring block.
 57. A methodaccording to claim 54, wherein the selected prediction method extendsimage details having a certain directionality into the block to bepredicted.
 58. A method according to claim 54, comprising: determining aclassification for at least two neighbouring blocks of said block to bepredicted according to the image contents of said neighbouring blocks;and selecting a sub-set of prediction methods from a set of availableprediction methods on the basis of a combination of the classificationsof said at least two neighbouring blocks.
 59. A method according toclaim 58, further comprising: receiving a signal indicative of aprediction method in said sub-set of prediction methods; selecting aprediction method for the block to be predicted from said sub-set ofprediction methods responsive to said received signal; and forming aspatial prediction for the block to be predicted using the selectedprediction method.